#ifndef __SPI_TX_RX_H
#define __SPI_TX_RX_H

#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <asm/ioctl.h>
#include <linux/spi/spidev.h>
#include<stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif


struct spidev_t
{
     char *device;
    uint32_t mode;
    uint8_t bits;
    uint32_t speed;
    uint16_t delay;
};



//w5500spi读写函数
uint8_t IINCHIP_READ(uint32_t addrbsb,int fd);
void IINCHIP_WRITE( uint32_t addrbsb,  uint8_t data,int fd);
uint16_t wiz_read_buf(int fd,uint32_t addrbsb, uint8_t* buf,uint16_t len);
uint16_t wiz_write_buf(int fd,uint32_t addrbsb,uint8_t* buf,uint16_t len);
//其它函数
static void pabort(const char *s);
void set_spidev(struct spidev_t *spidev,char * dev_name,uint8_t mode,uint8_t bits,int speed,int delay);
int open_spidev(struct spidev_t *spidev);
void  spi_init(int fd, int mode,int bits,int speed);//初始化spi设备,在打开设备符之后 使用



#ifdef __cplusplus
}
#endif
#endif